6. Error Handling
6.1 Introduction
This middleware function is responsible for handling errors that occur during the processing of license checks. It logs error details, updates the license check status, and sends a response to the client.
6.2 Functionality
- Logs the error details to the console for debugging purposes.
- Uses the
addLicenceCheckHistory
function to add a history record of the license check with a checkStatus of false, indicating a failed check. It also includes a custom error message 'Something went wrong in processing this check!' and, if available, the response code from the error. - Calls the
updateDriverLicenceCheckStat
function to update the driver's license check status to 'FAILED_LICENCE_CHECK'. - Updates the
requestingDriverLicenceCheck
field in the database for the specified driver, setting it to false. - Sends a JSON response to the client with an error message.
Status: Draft (Pending Review)
Category: Protected
Authored By: Sohan on Oct 05, 2023